﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Security;
using System.Security.Permissions;
namespace WebService
{
    /// <summary>
    /// Dành cho ngân hàng liên minh
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service2 : System.Web.Services.WebService
    {

       
        [WebMethod]
        public bool IsAuthenticated()
        {
            return Context.User.Identity.IsAuthenticated;
        }
        [WebMethod(Description = "Login dành cho ngân hàng khác")]
        public bool LoginBank(string UserName, String Password)
        {
            if (Membership.ValidateUser(UserName, Password))
            {
                FormsAuthentication.SetAuthCookie(UserName, true);
                return true;
            }
            return false;
        }

        [WebMethod]
        [PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
        public void LogOut()
        {
            if (Context.User.Identity.IsAuthenticated)
            {
                FormsAuthentication.SignOut();
            }
        }

    }
}
